package com.castile.sdk.nifi.client.service;

import com.castile.common.context.ContextManager;
import com.castile.sdk.nifi.client.NiFiClientManager;
import com.castile.sdk.nifi.client.api.DIONiFiServiceFactory;
import com.castile.sdk.nifi.client.api.NiFiClientService;
import com.castile.sdk.nifi.client.api.impl.DioNiFiClientService;
import com.castile.sdk.nifi.client.config.NiFiConfigManager;
import org.apache.nifi.api.toolkit.ApiException;
import org.apache.nifi.api.toolkit.model.ProcessorEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * 处理器服务
 * @author castile
 * @date 2025-05-16 下午10:03
 */
@Service
public class ProcessorService {

    @Autowired
    private NiFiClientManager niFiClientManager;

    /**
     * 根据processorID获取处理器信息
     *
     * @param id 处理器 id
     * @return ProcessorEntity
     * @throws ApiException 调用异常
     */
    public ProcessorEntity getById(String id) throws ApiException {
        NiFiClientService client = niFiClientManager.getClientById(ContextManager.getNifiClusterId());
        return client.getProcessorsApi().getProcessor(id);
    }
}
